package com.sxtx.vk.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.sxtx.vk.entity.User;
import com.sxtx.vk.entity.UserEntity;
import com.sxtx.vk.service.UserService;

@Controller
public class TestRestController {
	@Autowired
	private UserService userService;
	
	@RequestMapping(value = { "/getinfo" })
	@ResponseBody
	public Map<String,String> getInfo(){
		Map<String,String> info = new HashMap<>();
		info.put("username", "lxl");
		info.put("age", "3333");
		
		return info;
	}
	
	@RequestMapping(value = {"/getuser" })
	@ResponseBody
	public Object getUser(){
		User info = new User();
		info.setAge(2222);
		info.setUserName("dddd");
		return JSONObject.toJSON(info).toString();
	}
	
	
	@RequestMapping("/finduser/{id}")
	@ResponseBody
	public Object finduser(@PathVariable Integer id){
		UserEntity user =userService.selectByPrimaryKey(id);
		return user;
	}
}
